package com.ehotting.edsta.mqbd.signal.netty.config;


import com.alibaba.fastjson.JSON;
import com.ehotting.eaf.netty.action.NettyActionFactory;
import com.ehotting.eaf.netty.client.ConnectorIdleStateTrigger;
import com.ehotting.eaf.netty.domain.DataAble;
import com.ehotting.eaf.netty.loggers.NettyMsgSendLogger;
import com.ehotting.eaf.netty.sync.SyncFutureMapHelper;
import com.ehotting.edsta.mqbd.signal.api.domain.netty.HeartBeatRequest;
import com.ehotting.edsta.mqbd.signal.netty.handler.SiIdleStateTrigger;
import com.ehotting.edsta.mqbd.signal.netty.handler.SiTcpMultiClient;
import io.netty.bootstrap.Bootstrap;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

@Configuration
public class SignalAnalysisNettyConfig {

    @Bean("siNettyActionFactory")
    @DependsOn(value = "springUtils")
    NettyActionFactory siNettyActionFactory(){
        NettyActionFactory actionFactory = new NettyActionFactory();
        actionFactory.setScanPackage("com.ehotting.edsta.mqbd.signal.netty.action");
        return actionFactory;
    }

    @Bean
    public Bootstrap serverBootstrap(){
        return new Bootstrap();
    }

    @Bean(name="siSyncFutureMapHelper",initMethod = "start",destroyMethod = "stop")
    public SyncFutureMapHelper<DataAble> syncFutureMapHelper(){
        return new SyncFutureMapHelper<>();
    }

    @Bean
    public SiIdleStateTrigger siIdleStateTrigger(){
        SiIdleStateTrigger siIdleStateTrigger = new SiIdleStateTrigger();
        siIdleStateTrigger.setMsg(JSON.toJSONString(new HeartBeatRequest()));
        return siIdleStateTrigger;
    }


}